﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ThucThe;
using System.Data;
namespace KetNoi
{
    public class KhachHang_ketnoi
    {
        clsKetNoi kn = new clsKetNoi();
        public DataTable danhSachKhachHang()
        {
            return kn.LayDuLieu("KhachHang_load");
        }
        public int Them_KhachHang(KhachHang_thucthe kh)
        {
            int Nparameter = 6;
            string[] name = new string[Nparameter];
            object[] value = new object[Nparameter];
            name[0] = "@tenKhachHang"; value[0] = kh.TenKhachHang;
            name[1] = "@ngaySinh"; value[1] = kh.NgaySinh;
            name[2] = "@gioiTinh"; value[2] = kh.GioiTinh;
            name[3] = "@sdt"; value[3] = kh.Sdt;
            name[4] = "@email"; value[4] = kh.Email;
            name[5] = "@diaChi"; value[5] = kh.DiaChi;
            return kn.CapNhat("KhachHang_them", name, value, Nparameter);
        }
        public int Sua_KhachHang(KhachHang_thucthe kh)
        {
            int Nparameter = 7;
            string[] name = new string[Nparameter];
            object[] value = new object[Nparameter];
            name[0] = "@maKhachHang"; value[0] = kh.MaKhachHang;
            name[1] = "@tenKhachHang"; value[1] = kh.TenKhachHang;
            name[2] = "@ngaySinh"; value[2] = kh.NgaySinh;
            name[3] = "@gioiTinh"; value[3] = kh.GioiTinh;
            name[4] = "@sdt"; value[4] = kh.Sdt;
            name[5] = "@email"; value[5] = kh.Email;
            name[6] = "@diaChi"; value[6] = kh.DiaChi;
            return kn.CapNhat("KhachHang_sua", name, value, Nparameter);
        }
        public int Xoa_KhachHang(KhachHang_thucthe kh)
        {
            int Nparameter = 1;
            string[] name = new string[Nparameter];
            object[] value = new object[Nparameter];
            name[0] = "@maKhachHang";
            value[0] = kh.MaKhachHang;
            return kn.CapNhat("KhachHang_xoa", name, value, Nparameter);
        }
        public DataTable timKhachHang(KhachHang_thucthe kh)
        {
            int Nparameter = 1;
            string[] name = new string[Nparameter];
            object[] value = new object[Nparameter];
            name[0] = "@tenKhachHang";
            value[0] = kh.TenKhachHang;
            return kn.TimKiem("KhachHang_tim", name, value, Nparameter);
        }
    }
}
